package net.crowtheries.wirelessrouting.utils;

import ptolemy.data.IntToken;
import ptolemy.data.RecordToken;
import ptolemy.data.Token;
import ptolemy.kernel.util.IllegalActionException;

public class UDPSegment{

	private RecordToken segmentToken;
	private IntToken DSTP;
	private IntToken SRCP;
	private RecordToken DATA;
	
	public UDPSegment(int DSTP, int SRCP, RecordToken DATA) throws IllegalActionException{
		this.DSTP=new IntToken(DSTP);
		this.SRCP=new IntToken(SRCP);
		this.DATA=DATA;
		this.updateSegmentToken();
	}
	
	public UDPSegment(RecordToken SEG) throws IllegalActionException {
		this.DSTP=(IntToken)SEG.get("DSTP");
		this.SRCP=(IntToken)SEG.get("SRCP");
		this.DATA=(RecordToken)SEG.get("DATA");
		this.updateSegmentToken();
	}
	
	private void updateSegmentToken() throws IllegalActionException{
		segmentToken=new RecordToken(new String[]{
                "SRCP",
                "DSTP",
                "DATA"
            },new Token[]{
                 this.SRCP,
                 this.DSTP,
                 this.DATA
            });
	}

	public RecordToken getSegmentToken(){
		return this.segmentToken;
	}
	
	public int getDSTP(){
		return this.DSTP.intValue();
	}
	
	public int getSRCP(){
		return this.SRCP.intValue();
	}
	
	public RecordToken getDATA(){
		return this.DATA;
	}

}
